﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DBLibrary;
using System.Data;

namespace Billing2
{
    public class ClsLockDate
    {
        private int _IsNew = 1;
        public int IsNew
        {
            get
            {
                return _IsNew;
            }
            set
            {
                _IsNew = value;
            }
        }

        private DateTime _LockDate = DateTime.Now;
        public DateTime LockDate
        {
            get
            {
                return _LockDate;
            }
            set
            {
                _LockDate = value;
            }
        }
        private int _Range = 0;
        public int Range
        {
            get
            {
                return _Range;
            }
            set
            {
                _Range = value;
            }
        }

        private string _Reason = "";
        public string Reason
        {
            get
            {
                return _Reason;
            }
            set
            {
                _Reason = value;
            }
        }

        private long _CreatedBy;
        public long CreatedBy
        {
            get
            {
                return _CreatedBy;
            }
            set
            {
                _CreatedBy = value;
            }
        }


        private DateTime _CreatedDatetime;
        public DateTime CreatedDatetime
        {
            get
            {
                return _CreatedDatetime;
            }
            set
            {
                _CreatedDatetime = value;
            }
        }

        public int Save(ref string ErrorMessage)
        {
            int rtn = 0;
            ErrorMessage = "Successfully!";
            if (IsNew > 0)
                rtn = DBProcedures.Sp_BookingLockDate_Create(_LockDate, _Range, _Reason,_CreatedBy, ref rtn, ref ErrorMessage);
            else
                rtn = DBProcedures.Sp_BookingLockDate_Modify(_LockDate, _Range, _Reason, ref rtn, ref ErrorMessage);
            return rtn;
        }

        public int Delete(ref string ErrorMessage)
        {
            int rtn = 0;
            ErrorMessage = "Successfully!";
            rtn = DBProcedures.Sp_BookingLockDate_Delete(_LockDate, ref rtn, ref ErrorMessage);
            return rtn;
        }

        public static DataTable QueryAll()
        {
            DataTable rtn = null;
            DBProcedures.Sp_BookingLockDate_Query(ref rtn);
            return rtn;
        }

        public int Locate()
        {
            int result = 0;
            string msg = "";
            DBProcedures.Sp_BookingLockDate_Locate(_LockDate, ref _Range, ref _Reason,ref _CreatedBy,ref _CreatedDatetime, ref result, ref msg);
            return result;
        }

    }
}